package com.gtd.util

/**
 * TimeZone util for checking and getting correct timeZone
 *
 * @author  hoatle
 *          hoatlevan at gmail dot com
 * @since   1.0
 * @created Jul 6, 2009
 */
class TimeZoneUtil {

	 /**
	  * Checking whether timeZoneId existed
	  * If yes, return it. If no, return null
	  * @param tzId String
	  * @return Boolean
	  * @since  1.0
	  */
	 static existed(tzId) {
		 if (!tzId) {
			 return false
		 }
		 def tzIdList = TimeZone.getAvailableIDs()
		 if (tzIdList.contains(tzId)) {
			 return true
		 }
		 return false
	 }

	 /**
	  * Get all timezoneIds
	  * @return list
	  */
	 static getTimeZoneIds() {
		 return TimeZone.getAvailableIDs()
	 }

	 /**
	  * Get system default's timeZoneId
	  * @return tzId system's default
	  */
	 static getTimeZoneId() {
		 def tz = TimeZone.getDefault()
		 return tz.getID()
	 }
}